-- real lanterns?

-- 2023-01-17  Adding medium light level.

if not minetest.global_exists("lantern") then
	lantern = {}
	lantern.author = "boxface"
	lantern.version = 0.1
	lantern.date = "2022-07-07"
	lantern.modname = minetest.get_current_modname()
	lantern.modpath = minetest.get_modpath(lantern.modname)
	-- load register.lua only the first time
	dofile(lantern.modpath .. "/register.lua")
else
	if not lantern.author == "boxface" then
		local err = "[lantern] another mod registered my global variable"
		minetest.log("error", err)
		return false
	end
end

-- load other files
dofile(lantern.modpath .. "/lantern.lua")

function lantern.chat_debug(pname, message)
	if not debug then
		return
	end

	local msg = minetest.colorize("gold", message)
	minetest.chat_send_player(pname, msg)
end

if not lantern.registered then
	lantern.register()
	
	lantern.fix()
	
	lantern.registered = true
end

-- check for musttest_game reload mod
if minetest.get_modpath("reload") and not lantern.runonce then
	reload.register_file("lantern:init", lantern.modpath .. "/init.lua", false)
	reload.register_file("lantern:lantern", lantern.modpath ..
			"/lantern.lua", false)
	lantern.runonce = true
end
